<?php
// Inner Join daphuongtien On tintuc.MaBanTin=daphuongtien.MaDaPhuongTien
function xulyBanTin($mabantin)
{
	$mysql_str=mysql_query("Select * From tintuc Where MaBanTin=$mabantin");	
	$row=mysql_fetch_assoc($mysql_str);
	
?>
	<div class="blockbody2">
    <div class="newsacs">Ngày đưa tin: <?php echo dinhdangNgay($row['NgayDang']);?></div>
   
        <div class="atclear"></div>
 
    <div class="newstitle"><h1><?php echo $row['TenBanTin'];?></h1></div>
    <div class="newsintro"><p><?php echo $row['TieuDe'];?></p></div>
    <div class="newscontent"><table cellspacing="0" cellpadding="3" border="0" align="center" style="width: 1px;">
<tbody>
//<?php //if($row['HinhAnh2']!=""){?>
<tr>
<td><img width="500" height="336" alt="<?php echo $row['ChuDe'];?>" src="<?php //echo $row['HinhAnh2'];?>" style="border: 1px solid black;"></td>
</tr>
<?php // }
//	 if($row['HinhAnh3']!=""){?>
<tr>
<td><img width="500" height="336" alt="<?php echo $row['ChuDe'];?>" src="<?php //echo $row['HinhAnh3'];?>" style="border: 1px solid black;"></td>
</tr>
<?php //}?>
</tbody>
</table>
<?php echo $row['NoiDung'];?>
<p style="text-align: right;" class="Normal">Theo <em><strong><?php echo $row['TacGia'];?></strong></em></p>
<p><strong></strong></p></div>
        
        <div class="newsrelatedtitle">Các tin liên quan</div>
    <div class="newsrelated">
    	<ul>
    	<?php $mysql_str2=mysql_query("Select * From tintuc Where TenBanTin Like '%".$row['ChuDe']."%' And MaBanTin <> '".$mabantin."'");
			if(mysql_num_rows($mysql_str2)>0){
				while($row2=mysql_fetch_array($mysql_str2)){
		?>
    	
                	<li><a title="<?php echo $row2['TenBanTin'];?>" href="/banhang/tintuc/chitiet/bantin.php?bt=<?php echo $row2['MaBanTin'];?>"><?php echo $row2['TenBanTin'];?></a></li>
    	  <?php
                }
           }else{
				echo "<li>Hiện chưa có thông tin này.</li>";
			}?>
        </ul>
    </div>
        
  <div class="tab ui-tabs ui-widget ui-widget-content ui-corner-all" id="tabs">
        <div id="tittle_differ">Các tin khác</div>
        
        <div class="newsotherslist ui-tabs-panel ui-widget-content ui-corner-bottom" id="tabs_1">
	    	<ul>
            <?php $mysql_str2=mysql_query("Select * From tintuc Where  TenBanTin Not Like '%".$row['ChuDe']."%'");
			if(mysql_num_rows($mysql_str2)>0){
				while($row2=mysql_fetch_array($mysql_str2)){
		?>
    	
                	<li><a title="<?php echo $row2['TenBanTin'];?>" href="/banhang/tintuc/chitiet/bantin.php?bt=<?php echo $row2['MaBanTin'];?>"><?php echo $row2['TenBanTin'];?></a> - <span>[<?php echo dinhdangNgay($row2['NgayDang']);?>]</span></li>
    	  <?php
                }
           }else{
				echo "<li>Hiện chưa có thông tin này.</li>";
			}?>
            </ul>
       </div>
    </div>
</div>
<?php
}

function dinhdangNgay($NhapNgay){
	$items=array();
	$items=explode("-",$NhapNgay);
	for($i=0;$i<count($items);$i++){
		$year=$items[0];
		$month=$items[1];
		$day=$items[2];
	}
	return $time=$day."/".$month."/".$year;
}

?>

